// +build !16x12

package board

// the margin around the real board for calculating moves
const (
	borderTop    = 2
	borderBottom = 2
	borderLeft   = 4
	borderRight  = 3
)

// GetFile returns the file of the given square.
//
// GetFile requires a valid square as input. For invalid squares
// the behaviour of this function is undefined.
//
// todo: http://chessprogramming.wikispaces.com/Vector+Attacks#Implementations-15x12-Coordinate Transformation
// for a better formula
func GetFile(location Square) File {
	return File((location)%columnsInternalBoard-borderLeft) + A
}

// GetRank returns the rank of the given square.
//
// GetRank requires a valid square as input. For invalid squares
// the behaviour of this function is undefined.
func GetRank(location Square) Rank {
	return Rank(((int32(location)-19)*9)>>7) - 1 + Rank1
}

func SameColor(sq1, sq2 Square) bool {
	return (sq1^sq2)&1 == 0
}
